﻿package mortal.game.view.copy.ChallengeCopy.newView
{
    import com.mui.controls.*;
    import mortal.common.global.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.ChallengeCopy.data.*;

    public class ChallengeSectionRender extends GSprite
    {
        private var _challengData:ChallengeData;
        private var _btn:GLoadingButton;
        private var _name:GImageBitmap;
        private var _passInfo:GTextFiled;
        private var _selectSkin:GImageBitmap;
        private var _selected:Boolean;

        public function ChallengeSectionRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._btn = UIFactory.gLoadingButton("", 0, 0, 106, 96, this);
            this._selectSkin = UIFactory.gImageBitmap(ImagesConst.ChallengeSectionSelectBg, 7, -1, this);
            this._name = UIFactory.gImageBitmap("", 7, 68, null);
            this._name.onLoadCompl = this.updateNamePos;
            this._passInfo = UIFactory.gTextField("", 4, 52, 100, 20, this, GlobalStyle.textFormatBai.center());
            this._passInfo.mouseEnabled = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._btn.dispose(param1);
            this._btn = null;
            this._name.dispose(param1);
            this._name = null;
            this._selectSkin.dispose(param1);
            this._selectSkin = null;
            this._passInfo.dispose(param1);
            this._passInfo = null;
            EffectManager.glowFilterUnReg(this);
            this._challengData = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function updateNamePos() : void
        {
            if (isDisposed)
            {
                return;
            }
            if (this._name)
            {
                this._name.x = (this.width - this._name.width) * 0.5 - 7;
            }
            this.addChild(this._name);
            return;
        }// end function

        private function get passInfoTxt() : String
        {
            var _loc_1:String = null;
            var _loc_2:* = this._challengData.currentSectionMaxLevel;
            if (this._challengData.passLevel == 0)
            {
                _loc_1 = "<font color=\'#df2121\'>[";
            }
            else if (this._challengData.passLevel == _loc_2)
            {
                _loc_1 = "<font color=\'#FAD200\'>[";
            }
            else
            {
                _loc_1 = "<font color=\'#1ccc31\'>[";
            }
            _loc_1 = _loc_1 + this._challengData.passLevel + "/" + _loc_2 + "]</font>";
            return _loc_1;
        }// end function

        public function set selected(param1:Boolean) : void
        {
            this._selected = param1;
            this._selectSkin.visible = this._selected;
            this._btn.enabled = !this._selected;
            if (this._selected)
            {
                EffectManager.glowFilterReg(this);
            }
            else
            {
                EffectManager.glowFilterUnReg(this);
            }
            return;
        }// end function

        public function get selected() : Boolean
        {
            return this._selected;
        }// end function

        public function set challengData(param1:ChallengeData) : void
        {
            this._challengData = param1;
            this._name.imgUrl = "ExpeditionSectionName_" + ChallengeUtil.getSectionUrlByTChallenge(this._challengData.tChallengCopy);
            this._passInfo.htmlText = this.passInfoTxt;
            var _loc_2:* = "ChallengeSectionBtn_" + param1.tChallengCopy.tower + "_" + ((this._challengData.tChallengCopy.section - 1) % 4 + 1);
            this._btn.styleName = _loc_2;
            this._btn.drawNow();
            return;
        }// end function

        public function get challengData() : ChallengeData
        {
            return this._challengData;
        }// end function

    }
}
